//
//  LGRulerMeasureView.m
//  SportRing
//
//  Created by mykoma on 14-4-7.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "LGRulerMeasureView.h"

@interface LGRulerMeasureView() <LGRulerViewDelegate>

@end

@implementation LGRulerMeasureView

-(void)setupViews
{
    self.layer.borderColor = [UIColor grayColor].CGColor;
    self.layer.borderWidth = 2.0f;
    self.layer.cornerRadius = 4.0f;
    
    LGRulerView * rulerView = [[LGRulerView alloc] initWithFrame:self.bounds];
    rulerView.rulerDelegate = self;
    rulerView.showsHorizontalScrollIndicator = NO;
    rulerView.beginNum = self.beginNum;
    rulerView.endNum = self.endNum;
    rulerView.eachOffset = self.eachOffset;
    rulerView.direction = self.direction;
    if (rulerView.direction == LG_DIRECTION_TYPE_HORIZONTAL)
    {
        [rulerView setContentSize:CGSizeMake((self.endNum - self.beginNum) / self.eachOffset * [rulerView eachDistance], 0)];
    }
    else
    {
        [rulerView setContentSize:CGSizeMake(0, (self.endNum - self.beginNum) / self.eachOffset * [rulerView eachDistance])];
    }
    rulerView.selectOffset = 10;
    
    [self addSubview:rulerView];
}

#pragma mark - LGRulerViewDelegate

-(void)selectNumber:(NSNumber *)number
{
    if([self.delegate respondsToSelector:@selector(measureAtNumber:)])
    {
        [self.delegate measureAtNumber:number];
    }
}

@end
